package org.fglxy.mockserver;

import java.io.IOException;
import java.net.URISyntaxException;

import javax.script.ScriptException;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.google.protobuf.Descriptors.DescriptorValidationException;

//这三个注解等价于@SpringBootApplication,不信可以点进SpringBootApplication注解看一下
@Configuration // javabean配置注解
@EnableAutoConfiguration // 导入默认配置
@EnableAsync 
@SpringBootApplication
public class Application implements WebMvcConfigurer {

	@Override
	public void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/**").allowedOrigins("*").allowCredentials(true)
				.allowedMethods("GET", "POST", "DELETE", "PUT").maxAge(3600);
	}

	public static void main(String[] args) throws InterruptedException, DescriptorValidationException, IOException, URISyntaxException, ScriptException, NoSuchMethodException  {
		 SpringApplication.run(Application.class, args);
	}

}
